package ClassWork5;

// 人力资源部门类
public class HRDept extends Dept {
    public HRDept(String deptName) {
        super(deptName);
    }

    public void handleRecruitment() {
        System.out.println(getDeptName() + "处理了招聘");
    }
    // 招聘新员工并分配到指定部门
    public void recruitEmployee(Employee employee, Dept targetDept, Company company) {
        System.out.println("HR部门正在招聘员工：" + employee.getName());
        company.addEmployee(employee);
        targetDept.addEmployee(employee);
        System.out.println("员工 " + employee.getName() + " 已成功招聘并分配到 " + targetDept.getDeptName() + " 部门。");
    }

    // 开除员工方法
    public void fireEmployee(Employee employee, Company company) {
        System.out.println("HR部门正在开除员工：" + employee.getName());
        Dept employeeDept = company.findEmployeeDept(employee);
        if (employeeDept != null) {
            employeeDept.removeEmployee(employee);
        }
        company.removeEmployee(employee);
        System.out.println("员工 " + employee.getName() + " 已成功被开除。");
    }
}
